﻿using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace BeeTest.Samples
{
    [TestClass]
    public class CalculatorTests : BehaviorTestBase
    {
        [TestMethod]
        public void AddintTwoPositiveNumbersShouldGiveCorrectResult()
        {
            this.Returns.Given(CalculatorDefaultConstructed)
                .Returns.When(TwoNumbersAdded, 13, 45)
                .Then(ResultIsEqualTo, 58);
                
        }

        [TestMethod]
        public void AddIntsAlternative()
        {
            this.Returns.Given(() => { return new Calculator(); })
                .And.Returns.Given(13)
                .And.Returns.Given(45)
                .Returns.When((c, a, b) => { return c.Add(a, b); })
                .Then((r) => Assert.AreEqual(58, r));
                
        }

        #region Behaviors

        private Calculator CalculatorDefaultConstructed()
        {
            return new Calculator();
        }

        private int TwoNumbersAdded(Calculator c, int a, int b)
        {
            return c.Add(a, b);
        }

        private void ResultIsEqualTo(int given, int expected)
        {
            Assert.AreEqual(expected, given);
        }

        #endregion
    }
}
